//
//  KROnlienBurglarizedVC.m
//  KEREN
//
//  Created by MW on 2023/4/24.
//

#import "KROnlienBurglarizedVC.h"
#import "KRSettingCell.h"
#import "GaragelistViewController.h"
#import "KRRepairReportListVC.h"

@interface KROnlienBurglarizedVC ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate,TZImagePickerControllerDelegate,UIScrollViewDelegate>
{
    NSArray *_titleArr;
}
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) DeviceInfo *deviceInfo;
@property (nonatomic, copy) NSString *deteStr;
@property (nonatomic, strong) UIView *footerView;
@property (nonatomic, strong) UIView *bottomView;
@property (nonatomic, strong) UITextView *onTextView;
@property (nonatomic, strong) UIButton *addBtn;
@property (nonatomic, strong) UIView *imagesView;
@property (nonatomic, strong) UILabel *countLbl;
@property (nonatomic, strong) NSMutableArray *imgArrM;
@property (nonatomic, strong) UILabel *imgsTitLbl;
@property (nonatomic, strong) UIButton *confirmBtn;

@property (nonatomic, strong) UITableView *alertTableView;
@property (nonatomic, strong) UIScrollView *alertScrollView;
@property (nonatomic, strong) UIView  *alertView;
@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) NSMutableArray *seviceViewArrM;
@end

@implementation KROnlienBurglarizedVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self getNearby_stores];
    [self setNavViewWithRightTitle:@"" navColorIswhite:YES withTitle:@"在线报修"];
    _titleArr = @[@"车辆选择",@"网点名称",@"维修时间"];
    [self tableView];
    _deviceInfo = [[UserInfoManager sharedInstance] currentDeviceInfo];
    if(!_deviceInfo){
        if([UserInfoManager sharedInstance].deviceInfoList.count > 0){
            _deviceInfo = [UserInfoManager sharedInstance].deviceInfoList.lastObject;
        }
    }
    _deteStr = [[DeteManager shareInstance] getTodayStr];

    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    //注册、接收通知
    [center addObserver:self selector:@selector(chooseDevice:) name:CHOOSEDEVICE object:nil];
    self.tableView.tableFooterView = [self footerView];
    [center addObserver:self selector:@selector(uploagImgs) name:IMGSUPLOADFINISH object:nil];
    [[GDMapTool sharedInstance] getCurrentLocation:^{}];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[KRAlartManager shareInstance] resettingDeteRow];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [self.view endEditing:YES];
}

- (void)uploagImgs{
    WEAKSELF
    NSString *str = _onTextView.text;
    NSDictionary *parameters;
    if(_seviceNetWorkModel.Id){
        parameters = @{@"ebike_id":@(_deviceInfo.Id),@"desc":str,@"photo":[FlieUploadManager shareInstance].imgsArrM,@"store_id":@(_seviceNetWorkModel.Id)};
    }else{
        parameters = @{@"ebike_id":@(_deviceInfo.Id),@"desc":str,@"photo":[FlieUploadManager shareInstance].imgsArrM};
    }
    [NetworkingTool POST:@"/v1/app/repair/create" parameters:parameters isDeviceUrl:YES success:^(id  _Nonnull response, NSURLSessionDataTask * _Nonnull operation) {
        weakSelf.confirmBtn.enabled = YES;
        if([response[@"code"] intValue] == 0){
            if(weakSelf.isFromRepairReportListVC){
                [weakSelf.navigationController popViewControllerAnimated:YES];
            }else{
                KRRepairReportListVC *vc = [[KRRepairReportListVC alloc] init];
                [weakSelf.navigationController pushViewController:vc animated:YES];
            }
        }
    } failure:^(NSError * _Nonnull error, NSURLSessionDataTask * _Nonnull operation) {
        
    }];

}

- (void)confirm:(UIButton *)sender{
    sender.enabled = NO;
    WEAKSELF
    if(_imgArrM.count > 0){
        [[FlieUploadManager shareInstance] uploadImagesToOss:_imgArrM type:3];
    }else{
        NSDictionary *parameters;
        if(_seviceNetWorkModel.Id){
            parameters = @{@"ebike_id":@(_deviceInfo.Id),@"desc":_onTextView.text,@"store_id":@(_seviceNetWorkModel.Id)};

        }else{
             parameters = @{@"ebike_id":@(_deviceInfo.Id),@"desc":_onTextView.text};
        }
        [NetworkingTool POST:@"/v1/app/repair/create" parameters:parameters isDeviceUrl:YES success:^(id  _Nonnull response, NSURLSessionDataTask * _Nonnull operation) {
            sender.enabled = YES;
            if([response[@"code"] intValue] == 0){
                if(weakSelf.isFromRepairReportListVC){
                    [weakSelf.navigationController popViewControllerAnimated:YES];
                }else{
                    KRRepairReportListVC *vc = [[KRRepairReportListVC alloc] init];
                    [weakSelf.navigationController pushViewController:vc animated:YES];
                }
            }
        } failure:^(NSError * _Nonnull error, NSURLSessionDataTask * _Nonnull operation) {
            
        }];
    }
}

- (void)chooseDevice:(NSNotification *)notifacation{
    _deviceInfo = notifacation.object;
    [self.tableView reloadData];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _titleArr.count;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headView = [UIView new];
    headView.backgroundColor = [UIColor clearColor];
    return headView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.1f;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [self bottomView];
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    float imageWidth = (DEVICE_WIDTH - 96) / 3;
    if(self.imgArrM.count > 2){
        return imageWidth * 2 + 84  + 142;
    }else{
        return imageWidth + 68 + 142;
    }

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    KRSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"KRSettingCell"];
    cell.nameLbl.text = _titleArr[indexPath.row];
    cell.rightIcon.hidden = NO;
    cell.photoIcon.hidden = YES;
    cell.decLbl.text = @"";
    if(indexPath.row == 0){
        cell.decLbl.text = _deviceInfo.name;
    }else if (indexPath.row == 1){
        if(_seviceNetWorkModel){
            cell.decLbl.text = _seviceNetWorkModel.name;
        }else{
            cell.decLbl.text = @"";
        }
    }else if (indexPath.row == 2){
        cell.decLbl.text = _deteStr;
    }
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.view endEditing:YES];
    WEAKSELF
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if(indexPath.row == 0){
        GaragelistViewController *vc = [[GaragelistViewController alloc] init];
        [vc getDeviceList];
        vc.type = 1001;
        [self.navigationController pushViewController:vc animated:YES];
    }else if(indexPath.row == 1){
        if(_serviceArrM.count > 0){
            [UIView animateWithDuration:0.5 animations:^{
                weakSelf.alertView.frame = CGRectMake(0, DEVICE_HEIGHT - 500, DEVICE_WIDTH, 500);
            }];
            [weakSelf alertScrollView];
        }
    }else if(indexPath.row == 2){
        [[KRAlartManager shareInstance] showPickAlertView:@"选择日期" withcurrentIndex:1 IscanChooseHistory:NO changeTitleBlock:^(NSString * _Nonnull title) {
            weakSelf.deteStr = title;
            [self.tableView reloadData];
        }];
    }
}

- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto{
    [[FlieUploadManager shareInstance] getossToken];
    for (UIImage *img in photos) {
        [self.imgArrM addObject:img];
    }
    [self updateImagesView];
    [self.tableView reloadData];
}

- (void)getNearby_stores{
    WEAKSELF
    NSDictionary *ponit = @{@"lat":@(GDLOCATION.coordinate.latitude),@"lng":@(GDLOCATION.coordinate.longitude)};
    NSDictionary *parameters = @{@"coordinate":ponit};
    [NetworkingTool POST:Nearby_stores parameters:parameters isDeviceUrl:YES success:^(id  _Nonnull response, NSURLSessionDataTask * _Nonnull operation) {
        if([response[@"code"] intValue] == 0){
            if([response[@"data"][@"list"] isKindOfClass:[NSArray class]]){
                NSArray *arr = response[@"data"][@"list"];
                [weakSelf.serviceArrM removeAllObjects];
                for (int i = 0; i < arr.count; i ++) {
                    NSDictionary *dict = arr[i];
                    SeviceNetWorkModel *model = [SeviceNetWorkModel initWithDictionary:dict];
                    [weakSelf.serviceArrM addObject:model];
                }
            }
        }
    } failure:^(NSError * _Nonnull error, NSURLSessionDataTask * _Nonnull operation) {
        
    }];
}


- (void)textViewDidChange:(UITextView *)textView{
    
    if (textView.markedTextRange == nil && textView.text.length > 500) {
        textView.text = [textView.text substringToIndex:500];
    }
    _countLbl.text = [NSString stringWithFormat:@"%ld/500",textView.text.length];
}

- (void)addImage{
    [[FlieUploadManager shareInstance] getossToken];
    TZImagePickerController *imagePC = [[TZImagePickerController alloc]initWithMaxImagesCount:6 - self.imgArrM.count delegate:self];
    imagePC.allowTakePicture = YES;
    imagePC.allowTakeVideo = NO;
    imagePC.allowPickingVideo = NO;
    imagePC.allowPickingGif = NO;
    imagePC.showSelectedIndex = YES;
    imagePC.allowPickingOriginalPhoto = YES;//原图
    imagePC.minImagesCount = 0;
    imagePC.showSelectBtn = NO;
    imagePC.allowPreview = YES;
    imagePC.autoSelectCurrentWhenDone = YES;
    imagePC.modalPresentationStyle = 0;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self presentViewController:imagePC animated:YES completion:nil];
    });

}

- (void)delegateImg:(UIButton *)sender{
    [_imgArrM removeObjectAtIndex:sender.tag - 100];
    [self updateImagesView];
}

- (void)updateImagesView{
    if(_imgArrM.count == 6){
        _addBtn.hidden = YES;
    }else{
        _addBtn.hidden = NO;
    }
    float imageWidth = (DEVICE_WIDTH - 96) / 3;

    if(_imgArrM.count > 2){
        [_imagesView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.offset(imageWidth * 2 + 16);
        }];
    }else{
        [_imagesView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.offset(imageWidth);
        }];
    }
    for (id idView in _imagesView.subviews) {
        if([idView isKindOfClass:[UIImageView class]]){
            [idView removeFromSuperview];
        }
    }
    for (int i = 0; i < _imgArrM.count; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithImage:_imgArrM[i]];
        if(i < 3){
            imageView.frame = CGRectMake(24 + (imageWidth + 24) * i, 0, imageWidth, imageWidth);
        }else{
            imageView.frame = CGRectMake(24 + (imageWidth + 24) * (i - 3), imageWidth + 16, imageWidth, imageWidth);
        }
        imageView.layer.cornerRadius = 25;
        imageView.clipsToBounds = YES;
        [_imagesView addSubview:imageView];
        imageView.userInteractionEnabled = YES;
        UIButton *delegeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [imageView addSubview:delegeBtn];
        [delegeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.top.offset(0);
            make.width.height.offset(40);
        }];
        [delegeBtn setImage:[UIImage imageNamed:@"image_delete"] forState:UIControlStateNormal];
        delegeBtn.tag = 100 + i;
        [delegeBtn addTarget:self action:@selector(delegateImg:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    if(_imgArrM.count < 3){
        [_addBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.offset((24 + imageWidth) * _imgArrM.count + 24);
            make.top.offset(0);
            make.width.height.offset(imageWidth);
        }];
    }else{
        [_addBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.offset((24 + imageWidth) * (_imgArrM.count - 3) + 24);
            make.top.offset(imageWidth  + 16);
            make.width.height.offset(imageWidth);
        }];
    }
    _imgsTitLbl.text = [NSString stringWithFormat:@"上传图片（%ld/6）",_imgArrM.count];
}

- (UITableView *)tableView{
    if(!_tableView){
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NAVTOP_Height, DEVICE_WIDTH, DEVICE_HEIGHT - NAVTOP_Height) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = Main_BackColor;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        
        _tableView.rowHeight = 60;
        _tableView.estimatedRowHeight = 0;
        _tableView.estimatedSectionFooterHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
        
        if (@available(iOS 15.0, *)) {
            _tableView.sectionHeaderTopPadding = 0;
        }
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerNib:[UINib nibWithNibName:@"KRSettingCell" bundle:nil] forCellReuseIdentifier:@"KRSettingCell"];
        [self.view addSubview:_tableView];
        ///v1/app/repair/create
    }
    return _tableView;
}

- (void)serviceViewClick:(UITapGestureRecognizer *)tap{
    SeviceNetWorkModel *model = _serviceArrM[tap.view.tag];
    _seviceNetWorkModel = model;
    for (int i = 0; i < _seviceViewArrM.count; i ++) {
        UIView *view = _seviceViewArrM[i];
        for (id idView in view.subviews) {
            if([idView isKindOfClass:[UIImageView class]]) {
                UIImageView *imgView = (UIImageView *)idView;
                if(view.tag == tap.view.tag){
                    imgView.image = [UIImage imageNamed:@"select_icon_s"];
                }else{
                    imgView.image = [UIImage imageNamed:@"select_icon_u"];
                }
            }
        }
    }

}

- (void)sureBtnClick{
    [_alertScrollView removeAllSubviews];
    [_alertView removeAllSubviews];
    [_backView removeAllSubviews];
    [_alertScrollView removeFromSuperview];
    [_alertView removeFromSuperview];
    [_backView removeFromSuperview];
    _alertScrollView = nil;
    _alertView = nil;
    _backView = nil;
    [self.tableView reloadData];
}

- (NSMutableArray *)serviceArrM{
    if(!_serviceArrM){
        _serviceArrM = [NSMutableArray array];
    }
    return _serviceArrM;
}

- (UIView *)footerView{
    if(!_footerView){
        _footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DEVICE_WIDTH, 48 + 64 + BottomSpance_height)];
        _confirmBtn = [UIButton setButtonWithTitle:@"提交报修" titleColor:Whire_Color titleFont:BFont(16) cornerRadius:25 backColor:Color_7ACC00];
        [_footerView addSubview:_confirmBtn];
        [_confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-24);
            make.width.offset(DEVICE_WIDTH - 48);
            make.height.offset(48);
            make.bottom.offset(-BottomSpance_height);
        }];
        [_confirmBtn addTarget:self action:@selector(confirm:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _footerView;
}

- (UIScrollView *)alertScrollView{
    if(!_alertScrollView){
        [self.seviceViewArrM removeAllObjects];
        _alertScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 60, DEVICE_WIDTH, 300)];
        for (int i = 0; i < _serviceArrM.count; i++) {
            SeviceNetWorkModel *model = _serviceArrM[i];
            UIView *serviceView = [[UIView alloc] initWithFrame:CGRectMake(0, i * 60, DEVICE_WIDTH, 60)];
            [_alertScrollView addSubview:serviceView];
            UIImageView *imageView = [[UIImageView alloc] init];
            if(model.Id == _seviceNetWorkModel.Id){
                imageView.image = [UIImage imageNamed:@"select_icon_s"];
            }else{
                imageView.image = [UIImage imageNamed:@"select_icon_u"];
            }
            [serviceView addSubview:imageView];
            [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.offset(16);
                make.width.height.offset(20);
                make.centerY.equalTo(serviceView);
            }];
            UILabel *nameLbl = [UILabel setLblText:model.name font:Font(16) withColor:Black_Color inSubView:serviceView];
            [nameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(imageView.mas_right).offset(12);
                make.centerY.equalTo(serviceView);
                make.right.offset(-120);
            }];
            UILabel *distanceLbl = [UILabel setLblText:[NSString stringWithFormat:@"%.1f千米",model.distance / 1000.0] font:Font(16) withColor:Black_Color inSubView:serviceView];
            [distanceLbl mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.offset(-16);
                make.centerY.equalTo(serviceView);
            }];
            serviceView.tag = i;
            [self.seviceViewArrM addObject:serviceView];
            [UIView setLineViewWithframe:CGRectMake(0, 59, DEVICE_WIDTH, 1) forinView:serviceView];
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(serviceViewClick:)];
            [serviceView addGestureRecognizer:tap];
        }
        _alertScrollView.contentSize = CGSizeMake(DEVICE_WIDTH, 60 * _serviceArrM.count);
        [_alertView addSubview:_alertScrollView];
    }
    return _alertScrollView;
}

-(NSMutableArray *)imgArrM{
    if(!_imgArrM){
        _imgArrM = [NSMutableArray array];
    }
    return _imgArrM;
}

- (UIView *)bottomView{
    if(!_bottomView){
        float imageWidth = (DEVICE_WIDTH - 96) / 3;
        _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DEVICE_WIDTH, imageWidth + 52 + 142)];

        _bottomView.backgroundColor = Whire_Color;
        UILabel *tips = [UILabel setLblText:@"文字说明" font:Font(16) withColor:Color_333333 inSubView:_bottomView];
        [tips mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(16);
            make.left.offset(24);
        }];
        UIView *textbackView = [[UIView alloc] init];
        [_bottomView addSubview:textbackView];
        [textbackView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(24);
            make.right.offset(-24);
            make.height.offset(80);
            make.top.equalTo(tips.mas_bottom).offset(8);
        }];
        textbackView.layer.cornerRadius = 25;
        textbackView.clipsToBounds = YES;
        textbackView.layer.borderWidth = 1;
        textbackView.layer.borderColor = Color_EEEEEE.CGColor;
        _onTextView = [[UITextView alloc] init];
        _onTextView.delegate = self;
        _onTextView.textContainerInset = UIEdgeInsetsMake(12, 12, 12, 12);
        [textbackView addSubview:_onTextView];
        [_onTextView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.offset(0);
            make.height.offset(60);
            make.top.equalTo(tips.mas_bottom).offset(8);
        }];
        _onTextView.font = Font(14);
        _countLbl = [UILabel setLblText:@"0/500" font:Font(12) withColor:Color_B2B2B2 inSubView:_bottomView];
        [_countLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-36);
            make.top.equalTo(_onTextView.mas_bottom).offset(0);
        }];
        
        UIView *lineView =  [UIView setLineViewWithframe:CGRectZero forinView:_bottomView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(24);
            make.right.offset(-24);
            make.top.equalTo(textbackView.mas_bottom).offset(16);
            make.height.offset(1);
        }];
        
        _imgsTitLbl = [UILabel setLblText:@"上传图片（0/6）" font:Font(16) withColor:Color_333333 inSubView:_bottomView];
        [_imgsTitLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(24);
            make.top.equalTo(lineView.mas_bottom).offset(16);
        }];
        
        _imagesView = [[UIView alloc] init];
        [_bottomView addSubview:_imagesView];
        [_imagesView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.left.offset(0);
            make.height.offset(imageWidth);
            make.top.equalTo(_imgsTitLbl.mas_bottom).offset(16);
        }];
        
        _addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_imagesView addSubview:_addBtn];
        [_addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.offset(imageWidth);
            make.top.offset(0);
            make.left.offset(24);
        }];
        [_addBtn setImage:[UIImage imageNamed:@"image_add"] forState:UIControlStateNormal];
        [_addBtn addTarget:self action:@selector(addImage) forControlEvents:UIControlEventTouchUpInside];

    }
    return _bottomView;
}

- (UIView *)alertView{
    if(!_alertView){
        _backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DEVICE_WIDTH, DEVICE_HEIGHT)];
        _backView.backgroundColor = rgba(0, 0, 0, 0.3);
        UIWindow *window = UIApplication.sharedApplication.delegate.window;
        [window addSubview:_backView];

        _alertView = [[UIView alloc] initWithFrame:CGRectMake(0, DEVICE_HEIGHT, DEVICE_WIDTH, 500)];
        
        _alertView.backgroundColor = Whire_Color;
        UILabel *titleLbl = [UILabel setLblText:@"服务网点" font:BFont(20) withColor:Black_Color inSubView:_alertView];
        [titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(15);
            make.left.offset(16);
        }];
        UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_alertView addSubview:closeBtn];
        [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.offset(44);
            make.right.offset(6);
            make.centerY.equalTo(titleLbl);
        }];
        [closeBtn setImage:[UIImage imageNamed:@"NavBar_Default_Close"] forState:UIControlStateNormal];
        [UIView setLineViewWithframe:CGRectMake(0, 58, DEVICE_WIDTH, 1) forinView:_alertView];
        [_backView addSubview:_alertView];
        [closeBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside];
        UIButton *sureBtn = [UIButton setButtonWithTitle:@"确认" titleColor:Whire_Color titleFont:BFont(16) cornerRadius:25 backColor:Color_7ACC00];
        [_alertView addSubview:sureBtn];
        [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(400);
            make.left.offset(16);
            make.right.offset(-16);
            make.height.offset(58);
        }];
        [sureBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _alertView;
}

- (NSMutableArray *)seviceViewArrM{
    if(!_seviceViewArrM){
        _seviceViewArrM = [NSMutableArray array];
    }
    return _seviceViewArrM;
}

@end
